package cn.funeralobjects.upms.entity;

import cn.funeralobjects.common.annotations.CreateTime;
import cn.funeralobjects.common.annotations.Enable;
import cn.funeralobjects.common.annotations.Name;
import cn.funeralobjects.upms.converter.HttpMethodConverter;
import cn.funeralobjects.upms.converter.ProtocolConverter;
import cn.funeralobjects.upms.enums.HttpMethod;
import cn.funeralobjects.upms.enums.Protocol;
import cn.funeralobjects.util.converter.DefaultBooleanShortConverter;
import lombok.Data;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * API接口表
 *
 * @author FuneralObjects
 * Create date: 2020/4/26 10:24 AM
 */
@Data
@DynamicUpdate
@DynamicInsert
@Entity
@Table(name = "t_api")
@Accessors(chain = true)
public class EApi {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    /**
     * api所属范围
     */
    private String scope;

    /**
     * api名称
     */
    @Name
    private String name;

    /**
     * 协议
     */
    @Convert(converter = ProtocolConverter.class)
    private Protocol protocol;

    /**
     * http 的执行方法
     */
    @Convert(converter = HttpMethodConverter.class)
    private HttpMethod method;

    /**
     * url 路径
     */
    private String url;

    /**
     * 是否启用
     */
    @Enable
    @Convert(converter = DefaultBooleanShortConverter.class)
    private Boolean enable;
    /**
     * 创建日期
     */
    @CreateTime
    private Date createTime;
}
